Author: Michael Karcher <debian@mkarcher.dialup.fu-berlin.de>
Description: This patch redefines how BASE_MEMORY_FreeCheck works, and avoids
 tons of "may break strict aliasing rules" warnings. It also removes
 casts on invocation.

--- unace-nonfree-2.5.orig/source/apps/exe/messages/messages.c
+++ unace-nonfree-2.5/source/apps/exe/messages/messages.c
@@ -107,7 +107,7 @@ ULONG     Bits;
     
   APPS_EXE_MESSAGES_Skip(Start - 22);
 
-  BASE_MEMORY_FreeCheck((PVOID *) &APPS_EXE_MESSAGES.MessagesBuf);
+  BASE_MEMORY_FreeCheck(APPS_EXE_MESSAGES.MessagesBuf);
 
   if (!(APPS_EXE_MESSAGES.MessagesBuf =
         (PCHAR) BASE_MEMORY_GetMem(*Size + 1)))
--- unace-nonfree-2.5.orig/source/base/all/archives/read/read.c
+++ unace-nonfree-2.5/source/base/all/archives/read/read.c
@@ -22,8 +22,8 @@
 
 void    BASE_ARCHIVES_READ_FreeArchiveList(void)
 {
-  BASE_MEMORY_FreeCheck((PVOID *) &BASE_ARCHIVES_READ.FileData);
-  BASE_MEMORY_FreeCheck((PVOID *) &BASE_ARCHIVES_READ.FileNames);
+  BASE_MEMORY_FreeCheck(BASE_ARCHIVES_READ.FileData);
+  BASE_MEMORY_FreeCheck(BASE_ARCHIVES_READ.FileNames);
 }
 
 /*-----------------BASE_ARCHIVES_READ_GetArchiveList---------------------*/
--- unace-nonfree-2.5.orig/source/base/all/bufread/bufread.c
+++ unace-nonfree-2.5/source/base/all/bufread/bufread.c
@@ -134,7 +134,7 @@ void    BASE_BUFREAD_Close(void)
 {
   close(BASE_BUFREAD.Handle);
   BASE_BUFREAD.Handle = -1;
-  BASE_MEMORY_FreeCheck((PVOID *) &BASE_BUFREAD.Buf);
+  BASE_MEMORY_FreeCheck(BASE_BUFREAD.Buf);
 }
 
 /*-----------------BASE_BUFREAD_Tell-------------------------------------*/
--- unace-nonfree-2.5.orig/source/base/all/dcpr/comments/comments.c
+++ unace-nonfree-2.5/source/base/all/dcpr/comments/comments.c
@@ -45,7 +45,7 @@ void    BASE_DCPR_COMMENTS_Done(void)
 {
   if (BASE_DCPR.DoFreeReadBuf)
   {
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_DCPR.ReadBuf);
+    BASE_MEMORY_FreeCheck(BASE_DCPR.ReadBuf);
   }
 }
 
--- unace-nonfree-2.5.orig/source/base/all/dcpr/dcpr.c
+++ unace-nonfree-2.5/source/base/all/dcpr/dcpr.c
@@ -301,8 +301,8 @@ void    BASE_DCPR_Done(void)
 {
   if (BASE_DCPR.IsInitialized)
   {
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_DCPR.ReadBuf);
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_DCPR_LZ77.Dictionary);
+    BASE_MEMORY_FreeCheck(BASE_DCPR.ReadBuf);
+    BASE_MEMORY_FreeCheck(BASE_DCPR_LZ77.Dictionary);
     BASE_DCPR.IsInitialized = 0;
     BASE_MEMORY_Optimize();
   }
--- unace-nonfree-2.5.orig/source/base/all/dcpr/pic/pic.c
+++ unace-nonfree-2.5/source/base/all/dcpr/pic/pic.c
@@ -137,7 +137,7 @@ void    BASE_DCPR_PIC_Done(void)
     BASE_DCPR_PIC.Data[0] -= BASE_DCPR_PIC.Planes;
     BASE_DCPR_PIC.Data[1] -= BASE_DCPR_PIC.Planes;
 
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_DCPR_PIC.Data[0]);
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_DCPR_PIC.Data[1]);
+    BASE_MEMORY_FreeCheck(BASE_DCPR_PIC.Data[0]);
+    BASE_MEMORY_FreeCheck(BASE_DCPR_PIC.Data[1]);
   }
 }
--- unace-nonfree-2.5.orig/source/base/all/extract/extract.c
+++ unace-nonfree-2.5/source/base/all/extract/extract.c
@@ -232,10 +232,10 @@ UINT	  NTFSSecuritySize;
   {
     BASE_LFN_SetFileAttributes(BASE_STATE.DestinationFileName, Attr);
     BASE_DOSFUNCS_SetFileSecurity(BASE_STATE.DestinationFileName, NTFSSecurity);
-    BASE_MEMORY_FreeCheck((PVOID)&NTFSSecurity);
+    BASE_MEMORY_FreeCheck(NTFSSecurity);
   }
 
-  BASE_MEMORY_FreeCheck((PVOID *) &Buf);
+  BASE_MEMORY_FreeCheck(Buf);
 
   return;
 
--- unace-nonfree-2.5.orig/source/base/all/filelist/filelist.c
+++ unace-nonfree-2.5/source/base/all/filelist/filelist.c
@@ -290,7 +290,7 @@ INT       BufSize;
   if (!(BASE_FILELIST.ListFileData =
          (pBASE_FILELIST_FileData) BASE_MEMORY_GetMemBase2(&BufSize, 1)))
   {
-    BASE_MEMORY_FreeCheck((PVOID *) &BASE_FILELIST.List);
+    BASE_MEMORY_FreeCheck(BASE_FILELIST.List);
 
     return;
   }
@@ -303,8 +303,8 @@ INT       BufSize;
 
 void    BASE_FILELIST_Done(void)
 {
-  BASE_MEMORY_FreeCheck((PVOID *) &BASE_FILELIST.List);
-  BASE_MEMORY_FreeCheck((PVOID *) &BASE_FILELIST.ListFileData);
+  BASE_MEMORY_FreeCheck(BASE_FILELIST.List);
+  BASE_MEMORY_FreeCheck(BASE_FILELIST.ListFileData);
   BASE_MEMORY_Optimize();
 }
 
--- unace-nonfree-2.5.orig/source/base/all/lfn/lin.c
+++ unace-nonfree-2.5/source/base/all/lfn/lin.c
@@ -67,7 +67,7 @@ tLFN      SearchFile,
         }
       }
 
-      BASE_MEMORY_FreeCheck((PVOID*)&Env);
+      BASE_MEMORY_FreeCheck(Env);
     }
   }
 
--- unace-nonfree-2.5.orig/source/base/all/memory/memory.c
+++ unace-nonfree-2.5/source/base/all/memory/memory.c
@@ -150,13 +150,12 @@ INT       MemSize;
 
 /*-----------------BASE_MEMORY_FreeCheck---------------------------------*/
 
-void    BASE_MEMORY_FreeCheck(PVOID *Pointer)
+void    BASE_MEMORY_FreeCheck_(PVOID Pointer)
 {
-  if (*Pointer)
+  if (Pointer)
   {
-    BASE_MEMORY.MaxAllocate += BASE_MEMORY_Size(*Pointer);
-    free((PVOID) (((PULONG) *Pointer) - 1));
-    *Pointer = NULL;
+    BASE_MEMORY.MaxAllocate += BASE_MEMORY_Size(Pointer);
+    free((PVOID) (((PULONG) Pointer) - 1));
   }
 }
 
@@ -183,7 +182,7 @@ INT       OldSize,
   }
 
   memcpy(NewPointer, OldPointer, OldSize);
-  BASE_MEMORY_FreeCheck(&OldPointer);
+  BASE_MEMORY_FreeCheck(OldPointer);
 
   if (BASE_MEMORY_MemMax() < MemMaxSize)
   {
@@ -193,7 +192,7 @@ INT       OldSize,
     }
 
     memcpy(OldPointer, NewPointer, OldSize);
-    BASE_MEMORY_FreeCheck(&NewPointer);
+    BASE_MEMORY_FreeCheck(NewPointer);
 
     return OldPointer;
   }
--- unace-nonfree-2.5.orig/source/base/all/memory/memory.h
+++ unace-nonfree-2.5/source/base/all/memory/memory.h
@@ -32,7 +32,8 @@ PVOID   BASE_MEMORY_GetMemBase2Max(PINT
 PVOID   BASE_MEMORY_GetMemBase2PlusMax(PINT Size, INT Base, INT Maximum,
                                        INT Plus);
 
-void    BASE_MEMORY_FreeCheck(PVOID *Pointer);
+void    BASE_MEMORY_FreeCheck_(PVOID Pointer);
+#define BASE_MEMORY_FreeCheck(ptr) do { BASE_MEMORY_FreeCheck_(ptr); ptr=0; } while(0)
 PVOID   BASE_MEMORY_ReAlloc(PVOID OldPointer, INT NewSize);
 PVOID   BASE_MEMORY_ReAllocSameSize(PVOID OldPointer);
 void    BASE_MEMORY_InitAlloc(void);
